home *** CD-ROM | disk | FTP | other *** search
/ Total Network Tools 2002 / NextStepPublishing-TotalNetworkTools2002-Win95.iso / Archive / Misc Servers / Zope.exe / DTMLDOCUMENT.PY < prev    next >
Encoding:
Text File  |  2000-10-31  |  8.0 KB  |  206 lines

  1. ##############################################################################
  2. # Zope Public License (ZPL) Version 1.0
  3. # -------------------------------------
  4. # Copyright (c) Digital Creations.  All rights reserved.
  5. # This license has been certified as Open Source(tm).
  6. # Redistribution and use in source and binary forms, with or without
  7. # modification, are permitted provided that the following conditions are
  8. # met:
  9. # 1. Redistributions in source code must retain the above copyright
  10. #    notice, this list of conditions, and the following disclaimer.
  11. # 2. Redistributions in binary form must reproduce the above copyright
  12. #    notice, this list of conditions, and the following disclaimer in
  13. #    the documentation and/or other materials provided with the
  14. #    distribution.
  15. # 3. Digital Creations requests that attribution be given to Zope
  16. #    in any manner possible. Zope includes a "Powered by Zope"
  17. #    button that is installed by default. While it is not a license
  18. #    violation to remove this button, it is requested that the
  19. #    attribution remain. A significant investment has been put
  20. #    into Zope, and this effort will continue if the Zope community
  21. #    continues to grow. This is one way to assure that growth.
  22. # 4. All advertising materials and documentation mentioning
  23. #    features derived from or use of this software must display
  24. #    the following acknowledgement:
  25. #      "This product includes software developed by Digital Creations
  26. #      for use in the Z Object Publishing Environment
  27. #      (http://www.zope.org/)."
  28. #    In the event that the product being advertised includes an
  29. #    intact Zope distribution (with copyright and license included)
  30. #    then this clause is waived.
  31. # 5. Names associated with Zope or Digital Creations must not be used to
  32. #    endorse or promote products derived from this software without
  33. #    prior written permission from Digital Creations.
  34. # 6. Modified redistributions of any form whatsoever must retain
  35. #    the following acknowledgment:
  36. #      "This product includes software developed by Digital Creations
  37. #      for use in the Z Object Publishing Environment
  38. #      (http://www.zope.org/)."
  39. #    Intact (re-)distributions of any official Zope release do not
  40. #    require an external acknowledgement.
  41. # 7. Modifications are encouraged but must be packaged separately as
  42. #    patches to official Zope releases.  Distributions that do not
  43. #    clearly separate the patches from the original work must be clearly
  44. #    labeled as unofficial distributions.  Modifications which do not
  45. #    carry the name Zope may be packaged in any form, as long as they
  46. #    conform to all of the clauses above.
  47. # Disclaimer
  48. #   THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY
  49. #   EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  50. #   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  51. #   PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL DIGITAL CREATIONS OR ITS
  52. #   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  53. #   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  54. #   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  55. #   USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  56. #   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  57. #   OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  58. #   OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  59. #   SUCH DAMAGE.
  60. # This software consists of contributions made by Digital Creations and
  61. # many individuals on behalf of Digital Creations.  Specific
  62. # attributions are listed in the accompanying credits file.
  63. ##############################################################################
  64.  
  65.  
  66. def manage_addDocument(id, title):
  67.     """
  68.     Add a DTML Document to the current ObjectManager
  69.     """
  70.  
  71.  
  72. class DTMLDocument:
  73.     """
  74.     A DTML Document is a Zope object that contains and executes DTML
  75.     code. It is useful to represent web pages.
  76.     """
  77.     
  78.     __extends__=(
  79.         'OFSP.ObjectManagerItem.ObjectManagerItem',
  80.         'OFSP.PropertyManager.PropertyManager',
  81.         )
  82.     
  83.     def __call__(client=None, REQUEST={}, RESPONSE=None, **kw):
  84.         """
  85.  
  86.         Calling a DTMLDocument causes the Document to interpret the DTML
  87.         code that it contains.  The method returns the result of the
  88.         interpretation, which can be any kind of object.
  89.  
  90.         To accomplish its task, DTML Document often needs to resolve various
  91.         names into objects.  For example, when the code '<dtml-var
  92.         spam>' is executed, the DTML engine tries to resolve the name
  93.         'spam'.
  94.  
  95.         In order to resolve names, the Document must be passed a
  96.         namespace to look them up in.  This can be done several ways:
  97.  
  98.           * By passing a 'client' object -- If the argument 'client' is
  99.             passed, then names are looked up as attributes on the
  100.             argument.
  101.  
  102.           * By passing a 'REQUEST' mapping -- If the argument 'REQUEST'
  103.             is passed, then names are looked up as items on the
  104.             argument.  If the object is not a mapping, an TypeError
  105.             will be raised when a name lookup is attempted.
  106.  
  107.           * By passing keyword arguments -- names and their values can
  108.             be passed as keyword arguments to the Document.
  109.  
  110.         The namespace given to a DTML Document is the composite of
  111.         these three methods.  You can pass any number of them or none
  112.         at all. Names are looked up first in the keyword arguments,
  113.         then in the client, and finally in the mapping.
  114.  
  115.         A DTMLDocument implicitly pass itself as a client argument in
  116.         addition to the specified client, so names are looked up in
  117.         the DTMLDocument itself.
  118.  
  119.         Passing in a namespace to a DTML Document is often referred to
  120.         as providing the Document with a *context*.
  121.  
  122.         DTML Documents are called three ways:
  123.  
  124.           From DTML -- A DTML Document can be called from another DTML
  125.             Method or Document::
  126.  
  127.               <dtml-var standard_html_header>
  128.                 <dtml-var aDTMLDocument>
  129.               <dtml-var standard_html_footer>
  130.  
  131.             In this example, the Document 'aDTMLDocument' is being called
  132.             from another DTML object by name.  The calling method
  133.             passes the value 'this' as the client argument and the
  134.             current DTML names pace as the REQUEST argument.  The above
  135.             is identical to this following usage in a DTML Python
  136.             expression::
  137.  
  138.               <dtml-var standard_html_header>
  139.                 <dtml-var "aDTMLDocument(_.None, _)">
  140.               <dtml-var standard_html_footer>
  141.  
  142.           From Python -- Products, External Methods, and PythonMethods 
  143.             can call a DTML Document in the same way as calling a DTML
  144.             Document from a Python expression in DTML; as shown in the
  145.             previous example.
  146.  
  147.           By the Publisher -- When the URL of a DTML Document is fetched 
  148.             from Zope, the DTML Document is called by the publisher.
  149.             The REQUEST object is passes as the second argument to the 
  150.             Document.  
  151.           
  152.         Permission -- 'View'
  153.  
  154.         """
  155.  
  156.     def manage_edit(data, title):
  157.         """
  158.         Change the DTML Document, replacing its contents with 'data'
  159.         and
  160.         changing its title.
  161.         
  162.         The data argument may be a file object or a string.
  163.         
  164.         Permission -- 'Change DTML Documents'
  165.         """
  166.         
  167.     def document_src():
  168.         """
  169.         Returns the unrendered source text of the DTML Document.
  170.         
  171.         Permission -- 'View management screens'
  172.         """
  173.         
  174.     def get_size():
  175.         """
  176.         Returns the size of the unrendered source text of the DTML
  177.         Document in bytes.
  178.  
  179.         Permission -- 'View'
  180.         """
  181.  
  182.     __constructor__=manage_addDocument
  183.  
  184.  
  185.